//
//  CategoryListCollectionViewCell.m
//  FlyGift
//
//  Created by lanou3g on 15/7/16.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "CategoryListCollectionViewCell.h"
/**
 *  // 展示图片
 @property(nonatomic, strong)UIImageView *showImageView;
 // 标题
 @property(nonatomic, strong)UILabel *titleLabel;
 // 价格
 @property(nonatomic, strong)UILabel *priceLabel;
 // 喜欢的人数
 @property(nonatomic, strong)UILabel *favoriteLabel;
 // 红心
 @property(nonatomic, strong)UIImageView *heartImagevIew;
 */

@implementation CategoryListCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        self.showImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width)];
        self.showImageView.image = [UIImage imageNamed:@"default_avata@3x"];
        [self addSubview:_showImageView];
        
        self.heartButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.heartButton setBackgroundImage:[UIImage imageNamed:@"heart_w@3x"] forState:UIControlStateNormal];
        self.heartButton.frame = CGRectMake(frame.size.width - kP6width(30), kP6Height(10), kP6width(20), kP6width(20));
        [self addSubview:_heartButton];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(10), self.showImageView.frame.size.height, frame.size.width - kP6width(25), kP6Height(25))];
        self.titleLabel.text = @"白色字母碎花T恤";
        self.titleLabel.numberOfLines = 2;
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        self.titleLabel.textColor = [UIColor blackColor];
        [self addSubview:_titleLabel];
        
        
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(10), self.showImageView.frame.size.height  + self.titleLabel.frame.size.height, frame.size.width / 2, kP6Height(15))];
        self.priceLabel.text = @"99.00";
        self.priceLabel.font = [UIFont systemFontOfSize:12];
        self.priceLabel.textColor = [UIColor blackColor];
        [self addSubview:_priceLabel];
        
        self.favoriteLabel = [[UILabel alloc]initWithFrame:CGRectMake(frame.size.width / 2 + kP6width(10), self.priceLabel.frame.origin.y , (frame.size.width - kP6width(20)) / 2, kP6Height(15))];
        self.favoriteLabel.text = @"1314";
        self.favoriteLabel.font = [UIFont systemFontOfSize:12];
        self.favoriteLabel.textColor = [UIColor blackColor];
        [self addSubview:_favoriteLabel];
        
    }
    return self;
}

- (void)setCategoryListModel:(CategoryListModel *)categoryListModel
{
    if (_categoryListModel != categoryListModel)
    {
        _categoryListModel = categoryListModel;
    }
    
    [self.showImageView setImageWithURL:[NSURL URLWithString:self.categoryListModel.cover_image_url] placeholderImage:[UIImage imageNamed:@"default_avata@3x"]];
    self.titleLabel.text = self.categoryListModel.name;
    self.priceLabel.text = [NSString stringWithFormat:@"￥%@", self.categoryListModel.price];
    self.favoriteLabel.text = [NSString stringWithFormat:@"%ld人喜欢",self.categoryListModel.favorites_count];
   
}

@end
